home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 1 / Cream of the Crop 1.iso / PROGRAM / CUJ9204.ARJ / 1004010D < prev    next >
Text File  |  1992-06-02  |  351b  |  17 lines

  1. /* ldiv function */
  2. #include <stdlib.h>
  3.  
  4. ldiv_t (ldiv)(long numer, long denom)
  5.     {    /* compute long quotient and remainder */
  6.     ldiv_t val;
  7.  
  8.     val.quot = numer / denom;
  9.     val.rem = numer - denom * val.quot;
  10.     if (val.quot < 0 && 0 < val.rem)
  11.         {    /* fix remainder with wrong sign */
  12.         val.quot += 1;
  13.         val.rem -= denom;
  14.         }
  15.     return (val);
  16.     }
  17.